package com.timer.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 作者：LCG
 * 创建时间：2019/4/2 18:41
 * 描述：
 */
@Component
public class TaskService {

    @Autowired
    private ClientApi2 clientApi2;
    @Autowired
    private TaskMapper taskMapper;

    @Transactional
    public void yewu1(){

            List<Map<String, Object>> taskList = taskMapper.getTaskList ();

            for(Map<String,Object> map:taskList){
                Map<String,Object> order=map;
                order.put ( "id",map.get ( "orderId" ));
                //调用库存服务的接口锁定库存
                clientApi2.updateKucun ( order );
                //删除定时任务表中的数据
                taskMapper.delateTask ( map );
                System.out.println ("=======处理定时任务数据===="+map);
        }

    }


}
